package com.focus.xyz.union.pages.frontend;

import com.focus.xyz.core.common.keyword.Action;
import com.focus.xyz.core.utils.prop.ConfigPropInfo;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

/**
 * Created by chenmeng on 2016/3/30.
 */
public class MyUnion{
    @FindBy(xpath = "//button[contains(text(),'新增网站')]")
    private WebElement addWebSiteBtn;
    @FindBy(xpath = "//button[contains(text(),'立即推广')]")
    private WebElement addApiBtn;

    private String url = ConfigPropInfo.UNION_FRONT_MYUNION_URL;
    private Action action;

    public MyUnion(WebDriver driver,Action action){
        this.action = action;
        PageFactory.initElements(driver,this);
    }

    public void addWebSite() throws Exception{
        action.click(addWebSiteBtn);
    }

    public void linkAddApi() throws Exception{
        if(action.isElementExsit(By.xpath("//button[contains(text(),'立即推广')]"))){
            action.click(this.addApiBtn);
        }
    }
}
